//拦截器
import store from '../store';
import axios from "axios";

//  创建一个单例(实例)
const instance = axios.create({
    baseURL: "https://apis.netstart.cn/yunyuedu", //根路径
    timeout: 60 * 1000 //多少秒后超时
})

//请求拦截
instance.interceptors.request.use(config => {
        store.state.isLoading = true;
        return config;
    }, err => {
        return Promise.reject(err);
    })
    //响应拦截
instance.interceptors.response.use(res => {
    store.state.isLoading = false;
    return res.data;
}, err => {
    return Promise.reject(err);
})

export default instance;